<?php
/**
*btc列表
*/

require_once 'common.inc.php';
!in_array('2',$larr)&&adminmsg('你没有被赋予操作该项的权限！');

$matches=parse_url($_SERVER['HTTP_REFERER']);
if('trackerlist'==$action)
{
    $trackercontent='';
   if(file_exists('tracker.txt'))
   {
       
   	     $trackercontent=file_get_contents('tracker.txt');
		 
   }
   include_once MCC_ROOT.'/templates/msystem/autotracker.htm';
}
elseif('trackeredit'==$action)
{
	
    $trackertext='d8:announce';
	$arr=array();
	if(!$trackercontent)
	{
	    adminmsg('没有填写tracker','autotracker.inc.php?action=trackerlist');
		 exit();
	}
	$ftracker=fopen('tracker.txt','wb+');
	if($ftracker)
	{
	    fwrite($ftracker,$trackercontent);
		fclose($ftracker);
	}
	
	$arr=explode(';',$trackercontent);
	$i=0;
	$count=count($arr);
	for($i=0;$i<$count;$i++)
	{
	    if(strpos($arr[$i],'//'))
		{
		   	if($i==0)
			{
			 $arr[$i]=$arr[$i].'/announce';
			 $length=strlen($arr[$i]);
			 $trackertext.=$length.':'.$arr[$i];
	    	}
			else
			{
			 $arr[$i]=$arr[$i].'/announce';
			 $length=strlen($arr[$i]);
			 if($i==1)
			 	$trackertext.='13:announce-listll'.$length.':'.$arr[$i];
			 else
			 	$trackertext.=$length.':'.$arr[$i];
			 if($i==$count-1)
			 {
			 	 $trackertext.='ee';
			 }
			 else
			  $trackertext.='el';
			}
		}
	}
	$fp=fopen('../push/trackerlist.php','wb+');
	if($fp)
	{
	    fwrite($fp,$trackertext);
	   fclose($fp);
	}
	//include_once MCC_ROOT.'/templates/msystem/tracker.htm';
	adminmsg('添加成功','autotracker.inc.php?action=trackerlist');	
}

?>